import json
import os

class SparkConfig:
    def __init__(self):
        self.config = self._load_config()
        self.api_config = {
            'appid': "93595bf3",
            'api_key': "61556810d549b2a5cb22af49a83e782f",
            'api_secret': "NWI2MmUxM2VhNjBlNWNjOTBhZmFhZWJk",
            'domain': "4.0Ultra",
            'spark_url': "wss://spark-api.xf-yun.com/v4.0/chat"
        }
        
    def _load_config(self):
        config_path = os.path.join(os.path.dirname(__file__), 'role_config.json')
        try:
            with open(config_path, 'r', encoding='utf-8') as f:
                return json.load(f)
        except Exception as e:
            print(f"加载配置文件失败: {str(e)}")
            return {}
            
    def get_full_config(self):
        return {
            **self.api_config,
            **self.config.get('parameters', {}),
            'description': self.config.get('description', ''),
            'role_name': self.config.get('role_name', '')
        }